package com.example.controller;

import com.example.client.netty.DefaultNettyClientFactory;
import com.example.transport.message.PublishRequest;
import com.example.transport.message.Request;
import com.example.transport.message.Response;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.UUID;

@RestController
public class TestController {

    @Resource
    private DefaultNettyClientFactory defaultNettyClientFactory;

    @RequestMapping("send")
    public Response send() throws Exception {
        String uuid = UUID.randomUUID().toString();
        PublishRequest publishRequest = new PublishRequest(Request.PUBLISH, "test_topic", uuid);
        return defaultNettyClientFactory.syncSend(publishRequest);
    }
}
